//封装的缓动动画   水平动
function animation(obj, target, callback) {
    // console.log(callback); //callback=function(){}
    clearInterval(obj.timer)

    obj.timer = setInterval(function() {
        //(目标值-现在的位置)/10=  10 9 8.1
        var step = (target - obj.offsetLeft) / 10;
        step = step > 0 ? Math.ceil(step) : Math.floor(step) //缓动动画
        if (obj.offsetLeft == target) {
            clearInterval(obj.timer)
                //回调函数
            if (callback) {
                callback()
            }
        } else {
            obj.style.left = obj.offsetLeft + step + "px"
        }
    }, 15)
}